package com.wteam.dragon.system.util;

import cn.hutool.core.lang.Validator;
import cn.hutool.core.util.ObjectUtil;
import com.wteam.dragon.system.exception.BadRequestException;

/**
 * 验证工具
 * @Author 陈晓辉
 * @Date 2020/4/1 17:56
 */
public class ValidationUtil {
    /**
     * 验证是否为邮箱
     * @param email
     * @return
     */
    public static boolean isEmail(String email) {
        return Validator.isEmail(email);
    }

    /**
     * 判断obj是否为空
     * @param name
     * @param obj
     */
    public static void isNull(String name, Object obj){
        if(ObjectUtil.isNull(obj)){
            throw new BadRequestException(name + "不能为空");
        }
    }

    public static void isNull(String name, Object obj, String message){
        if(ObjectUtil.isNull(obj)){
            throw new BadRequestException(name + "为空:  " + message);
        }
    }
}
